/* Global styles and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

/* Main container - adapts to iframe or standalone */
#app-container {
    width: 100%;
    height: 450px; /* Default for iframe */
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Adjust height when opened in new tab */
@media (min-height: 600px) {
    body:not(.iframe-mode) #app-container {
        height: 90vh;
    }
}

/* Info icon for tooltip */
#info-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#info-icon:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

/* Tooltip styling */
.tooltip {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    max-width: 80%;
    text-align: center;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease;
}

.tooltip.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Progress bar */
#progress-container {
    position: absolute;
    top: 8px;
    left: 8px;
    width: calc(100% - 50px);
    max-width: 300px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    height: 24px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 20px;
}

#progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Score display */
#score-display {
    position: absolute;
    top: 40px;
    left: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.score-label {
    margin-right: 5px;
}

#score-value {
    color: #fbbf24;
    font-size: 16px;
}

/* Main content area */
#main-content {
    padding: 75px 10px 10px 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Story panel */
#story-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 70px;
}

#story-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    color: #1f2937;
}

#scenario-image {
    font-size: 40px;
    flex-shrink: 0;
}

/* Interactive area */
#interactive-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

/* Hazard card container */
#hazard-card-container {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

#hazard-card {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: move;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90%;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

#hazard-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    border-color: #fff;
}

#hazard-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.hazard-icon {
    font-size: 28px;
}

.hazard-text {
    font-size: 14px;
    font-weight: bold;
    color: #1f2937;
    line-height: 1.3;
}

/* P.E.E.P. zones */
#peep-zones {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.drop-zone {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 8px;
    border: 3px dashed rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.drop-zone:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.drop-zone.drag-over {
    background: rgba(167, 243, 208, 0.9);
    border-color: #10b981;
    border-style: solid;
    transform: scale(1.02);
}

.zone-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.zone-icon {
    font-size: 20px;
}

.zone-title {
    font-weight: bold;
    font-size: 13px;
    color: #1f2937;
}

.zone-description {
    font-size: 10px;
    color: #6b7280;
    margin-bottom: 6px;
    line-height: 1.2;
}

.dropped-items {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
}

.dropped-card {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: bold;
    color: #1f2937;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Feedback panel */
#feedback-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease;
}

#feedback-panel.hidden {
    display: none;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#feedback-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#feedback-icon {
    font-size: 36px;
    text-align: center;
}

#feedback-text {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    color: #1f2937;
}

#mitigation-text {
    font-size: 12px;
    color: #4b5563;
    line-height: 1.4;
    background: rgba(249, 250, 251, 0.8);
    padding: 8px;
    border-radius: 8px;
    border-left: 4px solid #10b981;
}

/* NEW: Risk reduction question section styles */
#risk-question-section {
    margin-top: 10px;
    padding: 10px;
    background: rgba(249, 250, 251, 0.9);
    border-radius: 8px;
    border: 2px solid #3b82f6;
}

#risk-question-section.hidden {
    display: none;
}

#risk-question-text {
    font-size: 13px;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 10px;
    text-align: center;
}

#risk-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.risk-option {
    background: white;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.risk-option:hover {
    background: #f3f4f6;
    border-color: #3b82f6;
    transform: translateX(5px);
}

.risk-option.selected {
    background: #dbeafe;
    border-color: #3b82f6;
    font-weight: bold;
}

.risk-option.correct {
    background: #d1fae5;
    border-color: #10b981;
    font-weight: bold;
}

.risk-option.incorrect {
    background: #fee2e2;
    border-color: #ef4444;
}

.risk-option.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* MODIFIED: Removed #risk-feedback styles as feedback element is no longer used */

/* Action buttons */
#action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 8px 0;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.btn-tertiary {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
}

.btn.hidden {
    display: none;
}

/* Results screen */
#results-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.5s ease;
}

#results-screen.hidden {
    display: none;
}

.results-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 20px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.results-content h2 {
    color: #1f2937;
    margin-bottom: 15px;
    font-size: 22px;
}

#final-score {
    font-size: 32px;
    font-weight: bold;
    color: #10b981;
    margin-bottom: 15px;
}

#performance-feedback {
    font-size: 16px;
    color: #4b5563;
    margin-bottom: 15px;
    line-height: 1.5;
}

#learning-summary {
    background: rgba(249, 250, 251, 0.8);
    padding: 12px;
    border-radius: 10px;
    font-size: 13px;
    color: #1f2937;
    margin-bottom: 15px;
    line-height: 1.5;
    text-align: left;
}

/* Correct/Incorrect animations */
.correct-answer {
    animation: correctPulse 0.6s ease;
}

.incorrect-answer {
    animation: incorrectShake 0.5s ease;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Responsive adjustments for smaller screens */
@media (max-width: 600px) {
    #peep-zones {
        grid-template-columns: 1fr;
    }
    
    .zone-description {
        font-size: 9px;
    }
    
    .btn {
        font-size: 12px;
        padding: 8px 16px;
    }
}

/* Touch-friendly targets */
@media (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    #hazard-card {
        min-height: 60px;
    }
    
    .drop-zone {
        min-height: 80px;
    }
}